<?php

use Illuminate\Database\Seeder;

use App\Tables\Role;
use App\Tables\User;

class UserRoleTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $role = Role::where('name', 'admin')->first();
        if (!empty($role)) {
            $user = User::where('name', 'admin')->where('type', 1)->first();
            if (!empty($user)) {
                $user->attachRole($role);
            }
        }

        $role = Role::where('name', 'system')->first();
        if (!empty($role)) {
            $user = User::where('name', 'system')->where('type', 1)->first();
            if (!empty($user)) {
                $user->attachRole($role);
            }
        }
    }
}
